package com.bwjf.authority.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.bwjf.authority.interceptor.GlobalInterceptor;
import com.bwjf.authority.interceptor.SessionInterceptor;

@Configuration
public class MyWebAppConfigurer extends WebMvcConfigurerAdapter {
    
    @Autowired
    @Qualifier("sessionInterceptor")
    private SessionInterceptor sessionInterceptor;
    
    @Autowired
    @Qualifier("globalInterceptor")
    private GlobalInterceptor globalInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        
        //配置session拦截器并忽略登陆页面
        registry.addInterceptor(globalInterceptor).addPathPatterns("/**");
        registry.addInterceptor(sessionInterceptor).addPathPatterns("/**")
            .excludePathPatterns("/login");
        super.addInterceptors(registry);
    }
}
